/*
===========================================================================
This source file is part of DyLab (Dynamic Laboratory)
For the latest info, see http://code.google.com/p/dylab/

Copyright (c) 2006-2008 Lukas Krejci
(krejci.lukas@volny.cz)

This file is part of DyLab.

    DyLab is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DyLab is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DyLab.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

#ifndef __dylab_ComModelLoader_h__
#define __dylab_ComModelLoader_h__

//===========================================================================================
#include <dylab/simobject/ComModelStructure.h>

//===========================================================================================
namespace dylab {

    /** Model structure loader component type.
	@remarks
		This component type has only one purpose: to load the given component of type ComModelStructure with data.
		The derived components are stateless. 
		It means, that in one place (method) the relevant component is created,
		then the method loadFromPropertyTree() is called, and afterwards the component is destroyed.
    */
    class DYLAB_EXPORT ComModelStructureLoader 
		: public ComponentBase<ComModelStructureLoader>
    {
	private:
		// model component that should be load when calling the loadFromPropertyTree method
		ComModelStructure * mModelToLoad;

    public:
        ComModelStructureLoader(const String & _componentName);

		/** Stores the pointer to the model structure, that this component should load with data.
		@remarks
			This method is called by the framework, 
			and is not intended to be used in components.
		@param[in] _comModel
			Pointer to the component representing a model structure, that should be loaded.
		*/
		void setModelToLoad(ComModelStructure * _comModel)
				{ DYLAB_ASSERT(_comModel != NULL); mModelToLoad = _comModel; }

		/** Returns a model structure component.
		@returns
			Previously stored pointer to a model structure component.
		@remarks
			Using this method, the derived components can recieves pointer to the model structure 
			that should be loaded with some data.			
		*/
		ComModelStructure * getModelToLoad() 
				{ DYLAB_ASSERT(mModelToLoad != NULL); return mModelToLoad; }
    };

}

//===========================================================================================
#endif // __dylab_ComModelLoader_h__
